package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "invoice_", schema = "crm")
public class Invoice {
    private int invoiceId;
    private Date invoiceDeliveryDate;
    private String invoiceDeliveryNo;
    private Integer invoiceDeliveryStatus;
    private String invoiceConsignor;
    private Integer invoiceDeliveryWay;
    private String invoiceCustomerName;
    private String invoiceEmpName;
    private String invoiceNote;
    private String invoiceContactName;
    private Collection<Deliveryrecord> deliveryrecordsByInvoiceId;
    private Contract contractByContractId;

    @Id
    @Column(name = "invoice_id", nullable = false)
    public int getInvoiceId() {
        return invoiceId;
    }

    public void setInvoiceId(int invoiceId) {
        this.invoiceId = invoiceId;
    }


    @Basic
    @Column(name = "invoice_delivery_date", nullable = true)
    public Date getInvoiceDeliveryDate() {
        return invoiceDeliveryDate;
    }

    public void setInvoiceDeliveryDate(Date invoiceDeliveryDate) {
        this.invoiceDeliveryDate = invoiceDeliveryDate;
    }

    @Basic
    @Column(name = "invoice_delivery_no", nullable = true, length = 255)
    public String getInvoiceDeliveryNo() {
        return invoiceDeliveryNo;
    }

    public void setInvoiceDeliveryNo(String invoiceDeliveryNo) {
        this.invoiceDeliveryNo = invoiceDeliveryNo;
    }

    @Basic
    @Column(name = "invoice_delivery_status", nullable = true)
    public Integer getInvoiceDeliveryStatus() {
        return invoiceDeliveryStatus;
    }

    public void setInvoiceDeliveryStatus(Integer invoiceDeliveryStatus) {
        this.invoiceDeliveryStatus = invoiceDeliveryStatus;
    }

    @Basic
    @Column(name = "invoice_consignor", nullable = true, length = 255)
    public String getInvoiceConsignor() {
        return invoiceConsignor;
    }

    public void setInvoiceConsignor(String invoiceConsignor) {
        this.invoiceConsignor = invoiceConsignor;
    }

    @Basic
    @Column(name = "invoice_delivery_way", nullable = true)
    public Integer getInvoiceDeliveryWay() {
        return invoiceDeliveryWay;
    }

    public void setInvoiceDeliveryWay(Integer invoiceDeliveryWay) {
        this.invoiceDeliveryWay = invoiceDeliveryWay;
    }

    @Basic
    @Column(name = "invoice_customer_name", nullable = true, length = 255)
    public String getInvoiceCustomerName() {
        return invoiceCustomerName;
    }

    public void setInvoiceCustomerName(String invoiceCustomerName) {
        this.invoiceCustomerName = invoiceCustomerName;
    }

    @Basic
    @Column(name = "invoice_emp_name", nullable = true, length = 255)
    public String getInvoiceEmpName() {
        return invoiceEmpName;
    }

    public void setInvoiceEmpName(String invoiceEmpName) {
        this.invoiceEmpName = invoiceEmpName;
    }

    @Basic
    @Column(name = "invoice_note", nullable = true, length = 255)
    public String getInvoiceNote() {
        return invoiceNote;
    }

    public void setInvoiceNote(String invoiceNote) {
        this.invoiceNote = invoiceNote;
    }

    @Basic
    @Column(name = "invoice_contact_name", nullable = true, length = 255)
    public String getInvoiceContactName() {
        return invoiceContactName;
    }

    public void setInvoiceContactName(String invoiceContactName) {
        this.invoiceContactName = invoiceContactName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Invoice invoice = (Invoice) o;
        return invoiceId == invoice.invoiceId &&
                Objects.equals(invoiceDeliveryDate, invoice.invoiceDeliveryDate) &&
                Objects.equals(invoiceDeliveryNo, invoice.invoiceDeliveryNo) &&
                Objects.equals(invoiceDeliveryStatus, invoice.invoiceDeliveryStatus) &&
                Objects.equals(invoiceConsignor, invoice.invoiceConsignor) &&
                Objects.equals(invoiceDeliveryWay, invoice.invoiceDeliveryWay) &&
                Objects.equals(invoiceCustomerName, invoice.invoiceCustomerName) &&
                Objects.equals(invoiceEmpName, invoice.invoiceEmpName) &&
                Objects.equals(invoiceNote, invoice.invoiceNote) &&
                Objects.equals(invoiceContactName, invoice.invoiceContactName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(invoiceId, invoiceDeliveryDate, invoiceDeliveryNo, invoiceDeliveryStatus, invoiceConsignor, invoiceDeliveryWay, invoiceCustomerName, invoiceEmpName, invoiceNote, invoiceContactName);
    }

    @OneToMany(mappedBy = "invoiceByInvoiceId")
    public Collection<Deliveryrecord> getDeliveryrecordsByInvoiceId() {
        return deliveryrecordsByInvoiceId;
    }

    public void setDeliveryrecordsByInvoiceId(Collection<Deliveryrecord> deliveryrecordsByInvoiceId) {
        this.deliveryrecordsByInvoiceId = deliveryrecordsByInvoiceId;
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }
}
